<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Make Controller Kit - Firmware API: network.c File Reference</title>
<link href="mt_doxygen.css" rel="stylesheet" type="text/css" />
<link href="../resources/mt_doxytabs.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.header {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 12pt;
	color: #222222;
}
-->
</style>
</head>

<body>
<table width="800" border="0">
    <tr>
      <td colspan="3">
        <form method="get" action="http://www.google.com/search">
          <div align="right">
            <input type="text"   name="q" size="25"
              maxlength="255" value="" />
            <input type="submit" value="Search" />
            <input type="hidden" name="sitesearch" value="makingthings.com/ref/firmware/html" />
          </div>
        </form>
       </td>
    </tr>
    <tr>
      <td><div align="center"><a href="http://www.makingthings.com">
				<img src="../resources/logo_brown_medium.png" alt="MakingThings"
									width="200" height="78" border="0" align="middle" longdesc="http://www.makingthings.com" /></a></div></td>
				<td><div align="center" class="header">
      		Make Controller Kit <br />
          Firmware API
      </div></td>
      <td><div align="center"><a href="http://www.makezine.com">
					<img src="../resources/make_logo.png" alt="MAKE Zine" 
										width="164" height="73" border="0" align="middle" longdesc="http://www.makezine.com" /></a></div></td>
    </tr>
</table>
</body>
</html>
<!-- Generated by Doxygen 1.5.4 -->
<script type="text/javascript">
<!--
function changeDisplayState (e){
  var num=this.id.replace(/[^[0-9]/g,'');
  var button=this.firstChild;
  var sectionDiv=document.getElementById('dynsection'+num);
  if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){
    sectionDiv.style.display='block';
    button.src='open.gif';
  }else{
    sectionDiv.style.display='none';
    button.src='closed.gif';
  }
}
function initDynSections(){
  var divs=document.getElementsByTagName('div');
  var sectionCounter=1;
  for(var i=0;i<divs.length-1;i++){
    if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){
      var header=divs[i];
      var section=divs[i+1];
      var button=header.firstChild;
      if (button!='IMG'){
        divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild);
        button=document.createElement('img');
        divs[i].insertBefore(button,divs[i].firstChild);
      }
      header.style.cursor='pointer';
      header.onclick=changeDisplayState;
      header.id='dynheader'+sectionCounter;
      button.src='closed.gif';
      section.id='dynsection'+sectionCounter;
      section.style.display='none';
      section.style.marginLeft='14px';
      sectionCounter++;
    }
  }
}
window.onload = initDynSections;
-->
</script>
<div class="tabs">
  <ul>
    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="modules.html"><span>Modules</span></a></li>
    <li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
    <li class="current"><a href="files.html"><span>Files</span></a></li>
    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
  </ul>
</div>
<h1>network.c File Reference</h1>Communicate with the Make Controller Board via Ethernet. <a href="#_details">More...</a>
<p>

<p>
<a href="network_8c-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="network_8c.html#35fd15dc15186da23f53198c1100ec2d">Network_SetPending</a> (int state)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Sets whether the Network subsystem is currently trying to negotiate its settings.  <a href="#35fd15dc15186da23f53198c1100ec2d"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___sockets.html#g7e4b76e6d4a93aa7c281e5cbba6cc584">Socket</a> (int address, int port)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Create a new TCP socket connected to the address and port specified.  <a href="group___sockets.html#g7e4b76e6d4a93aa7c281e5cbba6cc584"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___sockets.html#g838d1ceaf477b3496a9fe4adf8d28147">SocketRead</a> (void *socket, char *data, int length)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Read from a TCP socket.  <a href="group___sockets.html#g838d1ceaf477b3496a9fe4adf8d28147"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___sockets.html#gabf4d267c62d67bd596a22daea799662">SocketReadLine</a> (void *socket, char *data, int length)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Read a line from a TCP socket terminated by CR LF (0x0D 0x0A).  <a href="group___sockets.html#gabf4d267c62d67bd596a22daea799662"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___sockets.html#g1031bc0757e65ea265deb5dc3ded3029">SocketWrite</a> (void *socket, char *data, int length)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Write to a TCP socket.  <a href="group___sockets.html#g1031bc0757e65ea265deb5dc3ded3029"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___sockets.html#geab922d85a99bd7577f5e5b54628a5b4">SocketClose</a> (void *socket)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Close an existing TCP socket.  <a href="group___sockets.html#geab922d85a99bd7577f5e5b54628a5b4"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___sockets.html#g19a37ffe799e0d2de090a24a03e38cb7">ServerSocket</a> (int port)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Create a new TCP server socket and start listening for connections.  <a href="group___sockets.html#g19a37ffe799e0d2de090a24a03e38cb7"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___sockets.html#g17066cbe7e4510e8c89bba318140ff30">ServerSocketAccept</a> (void *serverSocket)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Accept an incoming connection to a ServerSocket that you have created.  <a href="group___sockets.html#g17066cbe7e4510e8c89bba318140ff30"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___sockets.html#gd698a1f1aa9b0f2864056a0790417179">ServerSocketClose</a> (void *serverSocket)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Close a ServerSocket that you have created.  <a href="group___sockets.html#gd698a1f1aa9b0f2864056a0790417179"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___sockets.html#g2cd3724da41c8c8235fa648a6fc9bcce">DatagramSocket</a> (int port)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Create a socket to read and write UDP packets.  <a href="group___sockets.html#g2cd3724da41c8c8235fa648a6fc9bcce"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___sockets.html#g5aa01e1403bafbfca35746bcd44a5c83">DatagramSocketSend</a> (void *datagramSocket, int address, int port, void *data, int length)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Send a UDP packet to a specified address.  <a href="group___sockets.html#g5aa01e1403bafbfca35746bcd44a5c83"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___sockets.html#ge810fd22358d4358b214bb99c20f363f">DatagramSocketReceive</a> (void *datagramSocket, int incomingPort, int *address, int *port, void *data, int length)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Receive a UDP packet.  <a href="group___sockets.html#ge810fd22358d4358b214bb99c20f363f"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___sockets.html#g2d63455f4c8feff3399c73f70e3300b7">DatagramSocketClose</a> (void *socket)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Close a <a class="el" href="group___sockets.html#g2cd3724da41c8c8235fa648a6fc9bcce" title="Create a socket to read and write UDP packets.">DatagramSocket()</a>.  <a href="group___sockets.html#g2d63455f4c8feff3399c73f70e3300b7"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___network.html#g0989090dd4929827de8708269f808e5b">Network_SetActive</a> (int state)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Sets whether the Network subsystem is active.  <a href="group___network.html#g0989090dd4929827de8708269f808e5b"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___network.html#gb1f4725187ab9011d327ed8e05e4746c">Network_GetActive</a> (void)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns the active state of the Network subsystem.  <a href="group___network.html#gb1f4725187ab9011d327ed8e05e4746c"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___network.html#g8efe3e0915b89c461da231653b7bd3b7">Network_SetAddress</a> (int a0, int a1, int a2, int a3)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set the IP address of the Make Controller.  <a href="group___network.html#g8efe3e0915b89c461da231653b7bd3b7"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___network.html#g8f1c006937cf5985de44cf8cd0751642">Network_SetMask</a> (int a0, int a1, int a2, int a3)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set the network mask of the Make Controller on your local network.  <a href="group___network.html#g8f1c006937cf5985de44cf8cd0751642"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___network.html#g1a5be7ffdac1a43d83f6c84369d0bb55">Network_SetGateway</a> (int a0, int a1, int a2, int a3)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set the gateway address for the local network the Make Controller is on.  <a href="group___network.html#g1a5be7ffdac1a43d83f6c84369d0bb55"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___network.html#gf5c24462c4ca5bfcf8a9ffdb80c290d8">Network_GetAddress</a> (int *a0, int *a1, int *a2, int *a3)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Read the board's current IP address.  <a href="group___network.html#gf5c24462c4ca5bfcf8a9ffdb80c290d8"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___network.html#ga0837a01a5bd814cae2a080f8b2bf86b">Network_GetMask</a> (int *a0, int *a1, int *a2, int *a3)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Read the board's current network mask.  <a href="group___network.html#ga0837a01a5bd814cae2a080f8b2bf86b"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___network.html#ge91ce5f124fcfbabc529d75fc222d49e">Network_GetGateway</a> (int *a0, int *a1, int *a2, int *a3)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Read the board's current gateway address.  <a href="group___network.html#ge91ce5f124fcfbabc529d75fc222d49e"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___network.html#gc61ff10637ea2e5a44c4af330693e9e0">Network_SetDhcpEnabled</a> (int enabled)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set whether DHCP is enabled.  <a href="group___network.html#gc61ff10637ea2e5a44c4af330693e9e0"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___network.html#ge24b6f9eecab6b6339bfc19524ff3f60">Network_GetDhcpEnabled</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Read whether DHCP is currently enabled.  <a href="group___network.html#ge24b6f9eecab6b6339bfc19524ff3f60"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___network.html#g8e37b3166ad4cafc5261e3de373e9261">Network_SetWebServerEnabled</a> (int state)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set whether the demo webserver is enabled.  <a href="group___network.html#g8e37b3166ad4cafc5261e3de373e9261"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___network.html#g371af21b1030735315a0c101aee27ace">Network_GetWebServerEnabled</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Read whether the demo webserver is enabled.  <a href="group___network.html#g371af21b1030735315a0c101aee27ace"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="network_8c.html#ee640cb0ab458e093969dcbdfed7e246">Network_SetValid</a> (int v)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Create a checksum for the current address settings and store it in EEPROM.  <a href="#ee640cb0ab458e093969dcbdfed7e246"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="network_8c.html#66046b3c42a64a18478cdcc685e22528">Network_GetValid</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Read the checksum for address settings in EEPROM, and determine if it matches the current settings.  <a href="#66046b3c42a64a18478cdcc685e22528"></a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Communicate with the Make Controller Board via Ethernet. 
<p>

<p>Definition in file <a class="el" href="network_8c-source.html">network.c</a>.</p>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="66046b3c42a64a18478cdcc685e22528"></a><!-- doxytag: member="network.c::Network_GetValid" ref="66046b3c42a64a18478cdcc685e22528" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int Network_GetValid           </td>
          <td>(</td>
          <td class="paramtype">void&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Read the checksum for address settings in EEPROM, and determine if it matches the current settings. 
<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>An integer specifying the validity of the settings - 1 (valid) or 0 (invalid). </dd></dl>

<p>Definition at line <a class="el" href="network_8c-source.html#l00987">987</a> of file <a class="el" href="network_8c-source.html">network.c</a>.</p>

</div>
</div><p>
<a class="anchor" name="35fd15dc15186da23f53198c1100ec2d"></a><!-- doxytag: member="network.c::Network_SetPending" ref="35fd15dc15186da23f53198c1100ec2d" args="(int state)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Network_SetPending           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>state</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Sets whether the Network subsystem is currently trying to negotiate its settings. 
<p>
This is mostly used by the Network init and deinit processes, so you shouldn't be calling this yourself unless you have a good reason to. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>state</em>&nbsp;</td><td>An integer specifying the pending state - 1 (pending) or 0 (not pending). </td></tr>
  </table>
</dl>

<p>Definition at line <a class="el" href="network_8c-source.html#l01022">1022</a> of file <a class="el" href="network_8c-source.html">network.c</a>.</p>

</div>
</div><p>
<a class="anchor" name="ee640cb0ab458e093969dcbdfed7e246"></a><!-- doxytag: member="network.c::Network_SetValid" ref="ee640cb0ab458e093969dcbdfed7e246" args="(int v)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int Network_SetValid           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>v</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Create a checksum for the current address settings and store it in EEPROM. 
<p>
This should be called each time an address setting is changed so that if the board gets powered down, it will know when it comes back up whether or not the address settings is currently has are valid.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>v</em>&nbsp;</td><td>An integer specifying whether to validate the current settings (1) or to force them to be invalidated (0). Passing in 0 returns the address settings to their factory defaults. </td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>0 on success. </dd></dl>

<p>Definition at line <a class="el" href="network_8c-source.html#l00943">943</a> of file <a class="el" href="network_8c-source.html">network.c</a>.</p>

</div>
</div><p>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Make Controller Kit</title>
<style type="text/css">
<!--
.footer {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 9pt;
	color: #999999;
}
-->
</style>
</head>

<body>
<hr size="1">
<div>
  <p class="footer">The Make Controller Kit is an open source project maintained by <a href="http://www.makingthings.com">MakingThings</a>.<br />
    MakingThings code is released under the <a href="http://www.apache.org/licenses/LICENSE-2.0.html" target="_blank">Apache 2.0 license</a>.<br />
    Bug tracker, development wiki and status can be found at <a href="http://dev.makingthings.com">http://dev.makingthings.com</a>.<br />
		This document was last updated on 5 Dec 2007.
</p>
</div>
<!-- Google Analytics Code -->
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-769030-1";
urchinTracker();
</script>
</body>
</html>
